<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
	a.thua__link_1:link { font-size: 14px; text-decoration: none;  color: #0b55c4; }
	a.thua__link_1:visited { font-size: 14px; color: #0b55c4; text-decoration: none; }
	a.thua__link_1:hover { font-size: 14px; text-decoration: none; color: #084095;  font-style: normal; }
</style>
<?php 
	//Tinh so trang
	function tinh_so_trang($so_gioi_han)
		{
			$sql="select count(*) from khuyen_mai";
			$sql1=mysql_query($sql);
			$data=mysql_fetch_row($sql1);
			$st=ceil($data[0]/$so_gioi_han);
			return $st;
		}
	$ssp_td=1;
	$sd=6;
	$so_gioi_han=$ssp_td*$sd;
	if($_GET['trang']=="")
	{
		$vtbd=0;
	}
	else 
	{
		$vtbd=($_GET['trang']-1)*$so_gioi_han;
	}
	$st=tinh_so_trang($so_gioi_han);
?>
<?php 
	//truy xuat CSDL lay thong tin khuyen mai
	$tv="select * from khuyen_mai order by id desc limit $vtbd,$so_gioi_han";
	$tv_1=mysql_query($tv);
?>
<a href="?thamso=them_km"><input type="button" value="Thêm tin khuyến mại" style="height:30px; width:200px"/></a>
<center>
    <!-- Khoi tao table luu thong tin khuyen mai-->
	<table width="980px" border="1" style="clear:left;margin:6px" id="er">
    	<tr>
            <td align="right" colspan="4">
                <span class="span__16">Tin khuyến mại</span>
            </td>
		</tr>
		<tr>
			<td width="100px" align="center"><b>Hình ảnh</b></td>
            <td width="300px" align="left" ><b>Tiêu đề</b></td>
			<td width="100px" align="center"><b>Sửa</b></td>
			<td width="100px" align="center"><b>Xóa</b></td>
		</tr>
		<?php 
			while($tv_2=mysql_fetch_array($tv_1))
			{

				$link_hinh="../image/banner/".$tv_2['hinh_anh'];
				$link_sua="?thamso=sua_km&id=".$tv_2['id'];
				$link_xoa="?thamso=xoa_km&id=".$tv_2['id'];
				?>
					<tr>
						<td align="center" height="100px">
							<a href="<?php echo $link_sua; ?>">
								<img src="<?php echo $link_hinh; ?>" width="90px" height="90px" border="0"/>
							</a>
						</td>
						<td  align="left" ><a href="<?php echo $link_sua; ?>" class="thua__link_1"><?php echo $tv_2['ten_km']; ?></a></td>
						<td align="center">
							<a href="<?php echo $link_sua; ?>" class="sua_xoa" style="color:red" >
								Sửa
							</a>
						</td>
						<td align="center">
							<a href="<?php echo $link_xoa; ?>" class="sua_xoa" style="color:red">
								Xóa
							</a>
						</td>
					</tr>
				<?php
			}
		?>
	</table>
      <?php
			echo "<div id='trang'>";
		for($i=1;$i<=$st;$i++)
		{
			$link="?thamso=tin_km&trang=$i";
			echo "<a href='$link' class='hello'><font size='4px'>";
			echo $i;
			echo "</font></a>";echo"  ";
		}
	echo "</div>";
		?>
        <div style="height:10px"></div>
</center>
<script>
	table_css_2("er");
</script>